﻿// Copyright (c) 2011 Blue Onion Software, All rights reserved
using System.Diagnostics.CodeAnalysis;
using System.IO;
using BlueOnionSoftware.Bloget;
using BlueOnionSoftware.Bloget.Providers;
using NUnit.Framework;

namespace BlogetTests
{
    [TestFixture]
    [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
    public class BlogTests
    {
        [Test]
        public void CreateBlog()
        {
            var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            try
            {
                var blog = Blog.Load(path);
                Assert.IsTrue(File.Exists(path));
            }

            finally
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
        }

        [Test]
        public void BackupBlog()
        {
            var blog = Blog.Load(@"..\..\..\BlogetExamples\App_Data\SampleBlog\Blog.xml");

            using (var fileStream = FileUtilities.OpenCreate("BlogBackup.zip"))
            {
                BlogProvider.DefaultProvider.Backup(blog, fileStream);
            }

            Assert.IsTrue(File.Exists("BlogBackup.zip"));
        }
    }
}